#!/bin/bash
# 打开 pages 文件夹，并创建文件
cd src/views_pc
for file in $(ls)
do
  if [ $file == $1 ];then
      echo $1' 文件已存在, 请使用其他名字'
      exit
  fi
done
mkdir $1
mkdir $1/components
cd $1

# 生成 $1.vue
echo "" > $1.vue
echo '<template>
  <page-frame class="mall-'$1'">
    test
  </page-frame>
</template>

<script>
	import PageFrame from "@cmpt_pc/frame"
  import '$1' from "@api/modules_pc/'$1'"
  export default {
    name: "'$1'",
    data(){
        return {}
    },
    components:{
      PageFrame
    },
    methods:{

    },
  }
</script>

<style lang="less" scoped>
  @import "~@style_pc/basic/utils/index";

</style>' > $1.vue

# 生成 $1.js
echo "" > $1.js
echo 'document.title = "'$1'"
localStorage.setItem("MOUNT_PATH", "'$1'/'$1'")
' > $1.js

# 生成store模块
# cd ../../store/modules_pc
# for file in $(ls)
# do
#   if [ $file == $1 ];then
#       echo $1' 文件已存在, 请使用其他名字'
#       exit
#   fi
# done
# echo "" > $1.js
# echo '// import { sms, login, UserInfo } from "@api/modules_pc/user"
# import * as types from "../types"

# const state = {}

# const actions = {}

# const getters = {}

# const mutations = {}

# export default {
#   state,
#   actions,
#   getters,
#   mutations
# }
# ' > $1.js

# 生成api模块
cd ../../api/modules_pc
for file in $(ls)
do
  if [ $file == $1 ];then
      echo $1' 文件已存在, 请使用其他名字'
      exit
  fi
done
echo "" > $1.js
echo 'import { 
  get, 
  post 
} from "../http"
export function '$1' () {return false;}
' > $1.js
